﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClipperHouse.jQuery.Base;
using System.Web.UI.WebControls;
using System.Web.UI;

namespace ClipperHouse.jQuery
{
	/// <summary>
	/// jQuery show() effect. See http://docs.jquery.com/Effects/show
	/// </summary>
	public class Show : JQueryWithSpeed
	{
		public Show()
		{
			this.SpeedIfRequired = "0";
		}

		public override string jQueryMethodName
		{
			get { return "show"; }
		}
	}

	public static partial class Extensions
	{
		public static JQuery Show(this Control caller, string speed, JQuery callback)
		{
			Show addedControl = new Show();
			addedControl.Speed = speed;

			if (callback != null)
			{
				addedControl.Callback.Add(callback);
			}

			if (caller is JQuery)
			{
				JQuery jqCaller = (caller as JQuery);
				jqCaller.Chain.Add(addedControl);
				return jqCaller;
			}
			else
			{
				addedControl.Target = "#" + caller.ClientID;
				caller.Page.Controls.Add(addedControl);
				return addedControl;
			}
		}

		public static JQuery Show(this Control caller, string speed)
		{
			return Show(caller, speed, null);
		}

		public static JQuery Show(this Control caller)
		{
			return Show(caller, String.Empty, null);
		}
	}
}
